import { FC } from "react"

import { SFormItem } from "@/components/common"
import StyleSelect from "@/components/common/styleSelect"
import { Toast } from "@/components/messages"
import { useLocale } from "@/locales"

const PageCode: FC<any> = ({ rules, selectorProps, options }) => {
	const { newFormat } = useLocale()

	const handleClick = () => {
		if (!options.length) {
			Toast.info(newFormat("common.please_select_section"))
			return
		}
	}

	return (
		<SFormItem colon name={"pageCode"} label={newFormat("common.action_page")} rules={rules}>
			<StyleSelect
				allowClear
				placeholder={newFormat("common.select_all")}
				options={options}
				onClick={handleClick}
				{...selectorProps}
			/>
		</SFormItem>
	)
}

export default PageCode
